home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / disasm.zip / UASM-STR.BAS < prev    next >
BASIC Source File  |  1988-06-03  |  10KB  |  185 lines

  1. 10 '--------------------------------------------------------------------------
  2. 11 '|    UASM-STR  1.06        23 Oct., 1983        White Crane Systems  |
  3. 12 '|    copyright 1983        Guy C. Gordon        3194 Friar Tuck Way  |
  4. 13 '|                              Doraville, GA 30340  |
  5. 14 '|                                         |
  6. 16 '|    This program takes the Unassemble output from UASM-INT and puts in   |
  7. 18 '|    the strings printed with DOSCALL PRINT$ (hex 09) and appends to the  |
  8. 20 '|    output file, (.STR) the assembler data definitions (DB insructions)  |
  9. 22 '|    that are needed to create the strings.  You may also enter up to     |
  10. 30 '|    10 address ranges (from DEBUG) and the program will find all strings |
  11. 32 '|    within that range and append them also.                     |
  12. 44 '|                                         |
  13. 46 '|    For best speed, and to save wear on your floppy disk drives,         |
  14. 48 '|    specify the input and output files on separate dirves.             |
  15. 50 '********************************* NOTICE *********************************
  16. 51 '*          USER SUPPORTED SOFTWARE (With thanks to Andrew Flugelman)     *
  17. 52 '*                                                                        *
  18. 53 '*   A limited license is granted to all users of this program, to make   *
  19. 54 '*   copies of this program and distribute them to other users subject    *
  20. 55 '*   to the following conditions:                                         *
  21. 56 '*           1.  None of the notices or credits are to be bypassed,       *
  22. 57 '*               altered, or removed.                                     *
  23. 58 '*           2.  The program is not to be distributed in modified form.   *
  24. 59 '*               (Users are encouraged to distribute MERGE files.)        *
  25. 60 '*           3.  No fee is to be charged (or any other consideration      *
  26. 61 '*               received) for copying or distributing the program        *
  27. 62 '*               without an express written agreement with                *
  28. 63 '*               White Crane Systems.                                     *
  29. 64 '**************************************************************************
  30. 70 CLS 'PRINT CHR$(27)+"E";   'CLS
  31. 71 PRINT "                                UASM-STR
  32. 72 PRINT "              White Crane Systems Unassembler - String Module
  33. 73 PRINT "
  34. 74 PRINT "           If you are using this program and finding it of value
  35. 75 PRINT "      please send  a cash contribution to support its upkeep and
  36. 76 PRINT "      distribution.   Use the UASM system  of programs to  unas-
  37. 77 PRINT "      semble one average length .COM file, look over the results
  38. 78 PRINT "      and calculate how many hours this would have taken you  to
  39. 79 PRINT "      to produce,  multiply by the minimum wage, contribute that
  40. 80 PRINT "      amount and use the programs free thereafter. If that's too
  41. 81 PRINT "      much just send $20.   Supporters will receive  free notice 
  42. 82 PRINT "      of enhancements and updates.
  43. 83 PRINT "           In any case you are encouraged to copy and distribute 
  44. 84 PRINT "      UASM to your friends provided you do so free of charge and
  45. 85 PRINT "      in unmodified form.
  46. 87 PRINT " 
  47. 88 PRINT "                           Guy C. Gordon
  48. 89 PRINT "                           White Crane Systems
  49. 90 PRINT "                           3194 Friar Tuck Way
  50. 91 PRINT "                           Doraville, GA 30340
  51. 92 PRINT " 
  52. 100    DEFINT A-Z
  53. 110    MAXS=200: DIM LIN$(MAXS), S$(MAXS)    'Max # of strings
  54. 120    TRUE=(1=1): FALSE=NOT TRUE
  55. 130    CR$=CHR$(13): LF$=CHR$(10): TAB$=CHR$(9): ESC$=CHR$(27): DQ$="'"
  56. 135    PRINT
  57. 140    INPUT "Enter name of  input file: ",INFILE$
  58. 150      DR=INSTR(INFILE$,":"): EXT=INSTR(INFILE$,".")
  59. 160      IF EXT=0 THEN INFILE$=INFILE$+".INT": EXT=INSTR(INFILE$,".")
  60. 170    INPUT "Enter name of output file: ",OUTFILE$
  61. 180      IF INSTR(OUTFILE$,":")=LEN(OUTFILE$) THEN OUTFILE$=OUTFILE$+MID$(INFILE$,DR+1,EXT-DR-1)
  62. 190      IF INSTR(OUTFILE$,".")=0 THEN OUTFILE$=OUTFILE$+".STR"
  63. 200    INPUT "Enter name of oiginal binary file: ",BINFILE$
  64. 210      IF INSTR(BINFILE$,":")=LEN(BINFILE$) THEN BINFILE$=BINFILE$+MID$(INFILE$,DR+1,EXT-DR-1)
  65. 220      IF INSTR(BINFILE$,".")=0 THEN BINFILE$=BINFILE$+".COM"
  66. 300 '-------------------------------------------------------------------------
  67. 301 '|                OPEN BINARY FILE & READ STRINGS             |
  68. 302 '-------------------------------------------------------------------------
  69. 310    PRINT: PRINT TIME$,"Reading "BINFILE$: PRINT
  70. 320    OPEN "R",#3,BINFILE$,1: FIELD #3, 1 AS N$
  71. 325    '        This field statement limits the .COM file to 32K
  72. 330    PRINT "Enter String Area addresses from DEBUG.  End list with a blank line."
  73. 340    PRINT "hhhh kkkk (range) or hhhh (single string address)"
  74. 350    FOR I=1 TO 10: LINE INPUT A$
  75. 360      AA$(I)=LEFT$(A$,4): AZ$(I)=MID$(A$,6,4)
  76. 370    IF AZ$(I)="" THEN AZ$(I)=AA$(I)
  77. 380    IF AA$(I)<>"" THEN NEXT I
  78. 400 '-------------------------------------------------------------------------
  79. 401 '|                LOOP THROUGH ADDRESS RANGES             |
  80. 402 '-------------------------------------------------------------------------    
  81. 410    FOR K=1 TO 10: IF AA$(K)="" THEN 500
  82. 420      START=VAL("&H"+AA$(K))
  83. 430      WHILE START<=VAL("&H"+AZ$(K))
  84. 440        GOSUB 1000            'Get string up to $ terminator
  85. 450        LIN$(L)=HEX$(START): IF START<&H1000 THEN LIN$(L)="0"+LIN$(L)
  86. 460        PRINT "D"+LIN$(L)+TAB$+"DB"+TAB$+S$(L)
  87. 470        START=ENDS+1
  88. 480      WEND         
  89. 490    NEXT K
  90. 500 '------------------------------------------------------------------------
  91. 501 '|                     OPEN FILES                        |
  92. 502 '------------------------------------------------------------------------
  93. 510    PRINT: PRINT TIME$,"Reading "INFILE$
  94. 520    PRINT ,"Writing "OUTFILE$: PRINT
  95. 530    OPEN  INFILE$ FOR  INPUT AS #1
  96. 540    OPEN OUTFILE$ FOR OUTPUT AS #2
  97. 600 '------------------------------------------------------------------------
  98. 601 '|                     MAIN LOOP                    | 
  99. 602 '------------------------------------------------------------------------ 
  100. 610    WHILE NOT EOF(1)
  101. 620      LINE INPUT #1,A$
  102. 630      IF MID$(A$,9,6)<>"PRINT$" THEN 770
  103. 640      '            make certain we have a hex address
  104. 650      IF MID$(A$,21,1)<"0" OR MID$(A$,21,1)>"F" OR MID$(A$,22,1)<"0" OR MID$(A$,22,1)>"F" OR MID$(A$,23,1)<"0" OR MID$(A$,23,1)>"F" OR MID$(A$,24,1)<"0" OR MID$(A$,24,1)>"F" THEN 770
  105. 660      D$=MID$(A$,21,4): START=VAL("&H"+D$)    'get string addr
  106. 700      IF START<&H100 THEN 770
  107. 710        I=1            'check for duplicates
  108. 720        WHILE I<=L: IF LIN$(I)=D$ THEN 740 ELSE I=I+1: WEND
  109. 730        GOSUB 1000: LIN$(L)=D$        'Go get string
  110. 735        I=L
  111. 740        PRINT "D"+D$+TAB$+"DB"+TAB$+S$(I)
  112. 750        PRINT #2, MID$(A$,1,14)+",D"+D$+TAB$+";"+S$(I)
  113. 760        GOTO 780
  114. 770      GOSUB 5000        'Check for DX,hhhh & if hhhh -> string
  115. 780    WEND
  116. 800 '------------------------------------------------------------------------
  117. 801 '|                WRITE DB STRINGS TO OUTFILE            |
  118. 802 '------------------------------------------------------------------------
  119. 810    PRINT #2, ";END CODE"
  120. 820    PRINT #2, ".RADIX    16"
  121. 830    PRINT #2, "CR    EQU    0D"
  122. 840    PRINT #2, "LF    EQU    0A"
  123. 850    PRINT #2, "TAB    EQU    09"
  124. 860    PRINT #2, "ESC    EQU    1B"
  125. 870    PRINT #2, "$    EQU    24"
  126. 900    '            LOOP THROUGH SAVED STRINGS
  127. 910    FOR I=1 TO L: PRINT #2, "D"+LIN$(I)+TAB$+"DB"+TAB$+S$(I): NEXT
  128. 920    '
  129. 930    PRINT: PRINT TIME$,"UASM-STR Complete"
  130. 999    END
  131. 1000 '-----------------------------------------------------------------------
  132. 1001 '|                GET STRING FROM BINARY FILE            |
  133. 1002 '-----------------------------------------------------------------------
  134. 1010    INSTRING=FALSE: STR.ERROR=FALSE
  135. 1020    L=L+1                        'New string
  136. 1030    I=START-&H100                     'adjust for 100h program prefix
  137. 1040    WHILE LEN(S$(L))<180 : I=I+1        'can't let string get too long
  138. 1050      IF I>LOF(3) THEN 3000            'or run past the EOF
  139. 1060      GET #3, I                'I'th char of file.COM into N$
  140. 1070      IF N$="$" THEN 4000            'Found string terminator
  141. 1080      IF N$<" " OR N$>"~" THEN 2000        'non-printing character
  142. 1090            'Found characters in a string
  143. 1100      IF NOT INSTRING THEN S$(L)=S$(L)+DQ$: INSTRING=TRUE
  144. 1120      S$(L)=S$(L)+N$
  145. 1130      GOTO 2999                'Read next character
  146. 2000 '-----------------------------------------------------------------------
  147. 2001 '|                NON-PRINTING CHARACTERS                |
  148. 2002 '-----------------------------------------------------------------------
  149. 2010